package com.se.mainView;

import com.se.utils.ServiceUtils;
import com.se.utils.StageManager;
import com.se.utils.StageType;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

public class MainViewApplication extends Application {
    @Override
    public void start(Stage stage) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(MainViewApplication.class.getResource("/com/se/mainView/MainView.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        stage.setTitle("聊天");
        stage.setScene(scene);
        stage.setOnCloseRequest(event -> {
            ServiceUtils.closeConnection();
            StageManager.remove(StageType.MAIN_STAGE);
            Platform.exit();
        });

        StageManager.add(StageType.MAIN_STAGE, stage);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}
